<%-- 
    Document   : rssortcurrency
    Created on : Nov 10, 2011, 1:18:00 PM
    Author     : Venus
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="java.util.*,Beans.ThamSoHT, Beans.TienTe,Models.ThamSoHT_Model"%>
<script type="text/javascript">
    function keypress(e){
            //Hàm dùng để ngăn người dùng nhập các ký tự khác ký tự số vào TextBox
            var keypressed = null;
            if (window.event)
            {
                keypressed = window.event.keyCode; //IE
            }
            else
            {
                keypressed = e.which; //NON-IE, Standard
            }
            if (keypressed < 48 || keypressed > 57 )
            { //CharCode của 0 là 48 (Theo bảng mã ASCII)
                //CharCode của 9 là 57 (Theo bảng mã ASCII)
                if (keypressed == 8 || keypressed == 127  )
                {//Phím Delete và Phím Back
                    return;
                }
                return false;
            }
        }
</script>
<%
            int langid = (Integer) session.getAttribute("langid"); // ngôn ngữ hiện tại
            String dsts = " 'symbols', 'status', 'rightmsg', 'order', 'notice', 'enable', 'disable', 'delete', 'currencyname', 'currencylist', 'all'  ";
            ThamSoHT[] mdsts = ThamSoHT_Model.DSThamSo(dsts, langid); // mảng chứa các tham số của trang này.

            String all = mdsts[0].getTenTS();
            String currencylist = mdsts[1].getTenTS();
            String currencyname = mdsts[2].getTenTS();
            String delete = mdsts[3].getTenTS();
            String disable = mdsts[4].getTenTS();
            String enable = mdsts[5].getTenTS();
            String notice = mdsts[6].getTenTS();
            String order = mdsts[7].getTenTS();
            String rightmsg = mdsts[8].getTenTS();
            String status = mdsts[9].getTenTS();
            String symbols = mdsts[10].getTenTS();

            String msgright = notice + "/" + rightmsg;
            
            Vector v = (Vector) request.getAttribute("DSTT");

            int numpage = 0;// khởi tạo số trang = 0
            int vsize = v.size();
            if (vsize % 4 == 0) // mỗi trang có 6 dòng
            {
                numpage = vsize / 4;
            } else {
                numpage = vsize / 4 + 1;
            }
            String xx = (String) request.getAttribute("item"); // trang hiện tại đang xem
            int item = Integer.parseInt(xx);
            String sapxep = (String) request.getAttribute("order");
            String test = (String) request.getAttribute("test");
            String sort = (String) request.getAttribute("sort");
            String sortkv = (String) request.getAttribute("sortkv");
            String sx1 = "";
            String sx2 = "";
            String sx3 = "";            
            String ud1 = "";
            String ud2 = "";
            String ud3 = "";            
            if(sapxep.equals("desc") ){
                   sx1 = "down";
                   sx2 = "down";
                   sx3 = "down";                   
                   ud1 = "down1";                   
                   ud2 = "down1";
                   ud3 = "down2";
            }            
            else if(sapxep.equals("asc") && test.equals("1")){
                    sx1 = "up";
                    sx2 = "down";
                    sx3 = "down";                    
                    ud1 = "up1";
                    ud2 = "down1";
                    ud3 = "down2";                    
            }
            else if(sapxep.equals("asc") && test.equals("2")){
                    sx1 = "down";
                    sx2 = "up";
                    sx3 = "down";                    
                    ud1 = "down1";
                    ud2 = "up1";
                    ud3 = "down2";                    
            }             
             else{
                    sx1 = "down";
                    sx2 = "down";
                    sx3 = "up";                    
                    ud1 = "down1";
                    ud2 = "down1";
                    ud3 = "up2";                    
             }
            int total = 0;
%>
<div class="title">
        <%=currencylist %>
    </div>
    <div class="content">
        <form name="dstiente" action="">
            <table class="mytable" border="0" cellpadding="0" cellspacing="0">
                <thead>
                    <tr>
                        <th style="width: 9%;  ">
                            
                            <input type="checkbox" onclick="CheckAllTT()">
                         
                        </th>
                        <th style="width: 10%;  "><%=order%></th>
                        <th style="width: 34%; ">
                            <a href="#" id="titledskv1" style="margin-top: 5px;" class="<%=sx1 %>" lang="<%=msgright%>"  name="1" onclick="SortTenTT(this.className, this.name, this.lang)">
                                <div style="float:left"><%=currencyname%></div>
                                <div id="sortkv1" style=" margin-right: 28px;" class="<%=ud1 %>"></div>
                            </a>
                        </th>
                        <th style="width: 20%; ">
                            <a href="#" id="titledskv2" style="margin-top: 5px;" class="<%=sx2 %>" lang="<%=msgright%>"  name="1" onclick="SortKyHieuTT(this.className, this.name, this.lang)">
                                <div style="float:left"><%=symbols%></div>
                                <div id="sortkv2" style=" margin-right: 25px;" class="<%=ud2 %>"></div>
                            </a>
                        </th>
                        <th style=" ">
                            <a href="#" id="titledskv3" style="margin-top: 5px;" class="<%=sx3 %>" lang="<%=msgright%>"  name="1" onclick="SortTTTT(this.className, this.name, this.lang)">
                                <div><%=status%></div>
                                <div >
                                    <div id="sortkv3" class="<%=ud3 %>"></div>
                                </div>
                            </a>
                        </th>
                    </tr>
                    <tr id="searchTienTe">
                        <th><img style=" margin-top: 2px; margin-left: 3px; margin-bottom: -7px; cursor: pointer;"  alt="1" lang="<%=msgright%>" onclick="SearchTT(this.alt, this.lang)" src="../images/search1.png"></th>
                        <th></th>
                        <th><input type="textbox" style=" width: 140px;" name="TENTT" class="tentt text" ></th>
                        <th><input type="textbox" style=" width: 75px;" name="KYHIEU" class="kyhieu text" ></th>
                        <th>
                            <div>
                                <select  class="tinhtrang" id="1" name="TINHTRANG" lang="<%=msgright%>" onchange="SearchTT(this.id, this.lang)">
                                    <option value="all"><%=all%></option>
                                    <option value="1"><%=enable%></option>
                                    <option value="0"><%=disable%></option>
                                </select>
                            </div>
                        </th>
                    </tr>
                </thead>
                <tbody>
                    <%
                        for (int i = (item - 1) * 4; i < (item - 1) * 4 + 4 && i < vsize; i++) {
                            Beans.TienTe tt = (Beans.TienTe) v.elementAt(i);
                            total = total + 1;
                    %>
                    <tr>
                        
                            <td class="STT"><input type="checkbox" value="<%= tt.getMaTTe() %>" class="optionTT" name="optionTT"></td>
                        
                        <td class="STT"><%= i + 1%></td>
                        <td><a href="#" name="<%=tt.getMaTTe() %>" lang="<%=msgright%>" onclick="ShowLangTT(this.name, this.lang)"><%= tt.getTenTTe()%></a></td>
                        <td><%=tt.getKyHieu() %></td>
                        <td>
                            <select  class="<%= tt.getMaTTe() %>" lang="<%=msgright%>" onchange="UpdateStatusTT(this.value,  this.className, this.lang)">
                                <%
                                    if (tt.getMacDinh() == 1) {%>
                                        <option value="1"><%= enable%></option>
                                        <option value="0"><%= disable%></option>
                                <%  } else {%>
                                        <option value="0"><%= disable%></option>
                                        <option value="1"><%= enable%></option>
                                <%  }
                                %>
                            </select>
                        </td>
                    </tr>
                    <%  }
                    %>
                    <input type="hidden" name="total" value="<%=total%>">
                </tbody>
            </table>
                <div style="float:left;">
                
                    <input type="button" style="margin-left: 0; margin-top: 5px; margin-bottom: 5px;" class="button" value ="<%=delete %>" id="1" lang="<%=msgright%>"  onclick="DeleteTT( this.id, this.lang)">
                
                </div>
            <div class="pagination" style=" margin-bottom: 5px;">
                <%
                    int trang = 1;
                    if (item > 1) {
                        trang = item - 1;
                    }
                %>
                <%
                    if (vsize > 4) {%>
                <%
                    if(sortkv.equals("tentt")){%>
                        <a href="#" id="<%=sort %>" class="prev"  name="<%= trang%>" lang="<%=msgright%>" onclick="SortTenTT(this.id, this.name, this.lang)">«</a>
                <%  }
                    else if(sortkv.equals("kyhieutt")){%>
                        <a href="#" id="<%=sort %>" class="prev"  name="<%= trang%>" lang="<%=msgright%>" onclick="SortKyHieuTT(this.id, this.name, this.lang)">«</a>
                <%  }
                    else{%>
                        <a href="#" id="<%=sort %>" class="prev"  name="<%= trang%>" lang="<%=msgright%>" onclick="SortTTTT(this.id, this.name, this.lang)">«</a>
                <%  }
                %>
                        
                <%
                        for (int c = 1; c <= numpage; c++) {
                            if (c != item) {
                %>
                <%
                    if(sortkv.equals("tentt")){%>
                        <a href="#" id="<%=sort %>" name="<%=c%>" lang="<%=msgright%>" onclick="SortTenTT(this.id, this.name, this.lang)"><%=c%></a>
                <%  }
                    else if(sortkv.equals("kyhieutt")){%>
                        <a href="#" id="<%=sort %>" name="<%=c%>" lang="<%=msgright%>" onclick="SortKyHieuTT(this.id, this.name, this.lang)"><%=c%></a>
                <%  }
                    else{%>
                        <a href="#" id="<%=sort %>" name="<%=c%>" lang="<%=msgright%>" onclick="SortTTTT(this.id, this.name, this.lang)"><%=c%></a>
                <%  }
                %>
                <%          } else {%><a class="current"> <%= c%></a> <% }
                        }
                %>
                <%      if (item + 1 <= numpage) {
                            trang = item + 1;
                        } else {
                            trang = item;
                        }
                %>
                <%
                    if(sortkv.equals("tentt")){%>
                        <a href="#" id="<%=sort %>" class="next"  name="<%= trang%>" lang="<%=msgright%>" onclick="SortTenTT(this.id, this.name, this.lang)">»</a>
                <%  }
                    else if(sortkv.equals("kyhieutt")){%>
                        <a href="#" id="<%=sort %>" class="next"  name="<%= trang%>" lang="<%=msgright%>" onclick="SortKyHieuTT(this.id, this.name, this.lang)">»</a>
                <%  }
                    else{%>
                        <a href="#" id="<%=sort %>" class="next"  name="<%= trang%>" lang="<%=msgright%>" onclick="SortTTTT(this.id, this.name, this.lang)">»</a>
                <%  }
                %>
                <%  }
                %>
            </div>
        </form>
    </div>